Note
Click here to download the full example code
Callosal bundles using AFQ API¶
An example using the AFQ API to find callosal bundles using the templates from: http://hdl.handle.net/1773/34926
import os.path as op
import plotly
from AFQ import api
from AFQ.mask import RoiMask
import AFQ.data as afd
Get some example data¶
Retrieves Stanford HARDI dataset.
afd.organize_stanford_data(clear_previous_afq=True)
Set tractography parameters (optional)¶
We make this tracking_params which we will pass to the AFQ object which specifies that we want 100,000 seeds randomly distributed in the ROIs of every bundle.
We only do this to make this example faster and consume less space.
tracking_params = dict(seed_mask=RoiMask(),
n_seeds=10000,
random_seeds=True,
rng_seed=42)
Initialize an AFQ object:¶
We specify bundle_info as the default bundles list (api.BUNDLES) plus the callosal bundle list. This tells the AFQ object to use bundles from both the standard and callosal templates.
myafq = api.AFQ(bids_path=op.join(afd.afq_home,
'stanford_hardi'),
dmriprep='vistasoft',
bundle_info=api.BUNDLES + api.CALLOSUM_BUNDLES,
tracking_params=tracking_params)
Out:
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1357.82 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1644.18 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 14.29 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1814.15 MB/s]
0%| | 0/29 [00:00<?, ? MB/s]
14%|#3 | 4/29 [00:00<00:00, 28.52 MB/s]
38%|###7 | 11/29 [00:00<00:00, 32.64 MB/s]
86%|########6 | 25/29 [00:00<00:00, 40.86 MB/s]
100%|##########| 29/29 [00:00<00:00, 68.28 MB/s]
0%| | 0/28 [00:00<?, ? MB/s]
11%|# | 3/28 [00:00<00:01, 21.35 MB/s]
29%|##8 | 8/28 [00:00<00:00, 24.24 MB/s]
82%|########2 | 23/28 [00:00<00:00, 31.55 MB/s]
100%|##########| 28/28 [00:00<00:00, 66.03 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1877.49 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1849.34 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2416.07 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1904.77 MB/s]
0%| | 0/23 [00:00<?, ? MB/s]
17%|#7 | 4/23 [00:00<00:00, 28.64 MB/s]
52%|#####2 | 12/23 [00:00<00:00, 33.63 MB/s]
100%|##########| 23/23 [00:00<00:00, 81.38 MB/s]
0%| | 0/22 [00:00<?, ? MB/s]
18%|#8 | 4/22 [00:00<00:00, 28.60 MB/s]
68%|######8 | 15/22 [00:00<00:00, 35.30 MB/s]
100%|##########| 22/22 [00:00<00:00, 77.91 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1733.90 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1829.18 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.78 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.71 MB/s]
0%| | 0/24 [00:00<?, ? MB/s]
17%|#6 | 4/24 [00:00<00:00, 28.50 MB/s]
33%|###3 | 8/24 [00:00<00:00, 28.45 MB/s]
96%|#########5| 23/24 [00:00<00:00, 36.46 MB/s]
100%|##########| 24/24 [00:00<00:00, 56.64 MB/s]
0%| | 0/24 [00:00<?, ? MB/s]
17%|#6 | 4/24 [00:00<00:00, 28.72 MB/s]
58%|#####8 | 14/24 [00:00<00:00, 34.97 MB/s]
100%|##########| 24/24 [00:00<00:00, 84.14 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1730.32 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1824.40 MB/s]
0%| | 0/28 [00:00<?, ? MB/s]
14%|#4 | 4/28 [00:00<00:00, 28.68 MB/s]
39%|###9 | 11/28 [00:00<00:00, 32.87 MB/s]
100%|##########| 28/28 [00:00<00:00, 79.69 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1774.99 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1851.79 MB/s]
0%| | 0/25 [00:00<?, ? MB/s]
16%|#6 | 4/25 [00:00<00:00, 28.57 MB/s]
44%|####4 | 11/25 [00:00<00:00, 32.74 MB/s]
100%|##########| 25/25 [00:00<00:00, 70.90 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 14.39 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1817.29 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 374.09 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1848.53 MB/s]
0%| | 0/21 [00:00<?, ? MB/s]
19%|#9 | 4/21 [00:00<00:00, 28.31 MB/s]
71%|#######1 | 15/21 [00:00<00:00, 35.02 MB/s]
100%|##########| 21/21 [00:00<00:00, 74.16 MB/s]
0%| | 0/21 [00:00<?, ? MB/s]
19%|#9 | 4/21 [00:00<00:00, 28.60 MB/s]
52%|#####2 | 11/21 [00:00<00:00, 32.77 MB/s]
100%|##########| 21/21 [00:00<00:00, 73.59 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1808.67 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1731.75 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1867.46 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1818.87 MB/s]
0%| | 0/29 [00:00<?, ? MB/s]
14%|#3 | 4/29 [00:00<00:00, 27.88 MB/s]
52%|#####1 | 15/29 [00:00<00:00, 34.53 MB/s]
100%|##########| 29/29 [00:00<00:00, 100.97 MB/s]
0%| | 0/29 [00:00<?, ? MB/s]
14%|#3 | 4/29 [00:00<00:00, 28.38 MB/s]
52%|#####1 | 15/29 [00:00<00:00, 35.07 MB/s]
100%|##########| 29/29 [00:00<00:00, 99.11 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1874.13 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1828.38 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1868.29 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2534.32 MB/s]
0%| | 0/28 [00:00<?, ? MB/s]
14%|#4 | 4/28 [00:00<00:00, 28.50 MB/s]
54%|#####3 | 15/28 [00:00<00:00, 35.19 MB/s]
100%|##########| 28/28 [00:00<00:00, 95.76 MB/s]
0%| | 0/27 [00:00<?, ? MB/s]
15%|#4 | 4/27 [00:00<00:00, 28.49 MB/s]
41%|#### | 11/27 [00:00<00:00, 32.65 MB/s]
100%|##########| 27/27 [00:00<00:00, 76.39 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1707.08 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1903.04 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2676.65 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1774.24 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 14.34 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1981.25 MB/s]
0%| | 0/32 [00:00<?, ? MB/s]
12%|#2 | 4/32 [00:00<00:00, 28.56 MB/s]
41%|#### | 13/32 [00:00<00:00, 34.24 MB/s]
100%|##########| 32/32 [00:00<00:00, 90.74 MB/s]
0%| | 0/30 [00:00<?, ? MB/s]
13%|#3 | 4/30 [00:00<00:00, 28.59 MB/s]
43%|####3 | 13/30 [00:00<00:00, 34.26 MB/s]
100%|##########| 30/30 [00:00<00:00, 85.12 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1689.89 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 2548.18 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1814.15 MB/s]
0%| | 0/1 [00:00<?, ? MB/s]
100%|##########| 1/1 [00:00<00:00, 1817.29 MB/s]
0%| | 0/23 [00:00<?, ? MB/s]
17%|#7 | 4/23 [00:00<00:00, 28.74 MB/s]
57%|#####6 | 13/23 [00:00<00:00, 34.42 MB/s]
100%|##########| 23/23 [00:00<00:00, 81.56 MB/s]
0%| | 0/22 [00:00<?, ? MB/s]
18%|#8 | 4/22 [00:00<00:00, 28.56 MB/s]
68%|######8 | 15/22 [00:00<00:00, 35.25 MB/s]
100%|##########| 22/22 [00:00<00:00, 77.82 MB/s]
0%| | 0/26 [00:00<?, ? MB/s]
15%|#5 | 4/26 [00:00<00:00, 28.57 MB/s]
46%|####6 | 12/26 [00:00<00:00, 33.56 MB/s]
100%|##########| 26/26 [00:00<00:00, 73.66 MB/s]
0%| | 0/23 [00:00<?, ? MB/s]
17%|#7 | 4/23 [00:00<00:00, 28.74 MB/s]
35%|###4 | 8/23 [00:00<00:00, 28.68 MB/s]
61%|###### | 14/23 [00:00<00:00, 31.83 MB/s]
100%|##########| 23/23 [00:00<00:00, 54.56 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 53.30 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.64 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 2278.89 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.72 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.95 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.69 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.92 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.94 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.67 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.84 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 2215.11 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 29.01 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 1923.99 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.73 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 28.87 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 3297.41 MB/s]
0%| | 0/2 [00:00<?, ? MB/s]
100%|##########| 2/2 [00:00<00:00, 3524.63 MB/s]
Visualizing bundles and tract profiles:¶
This would run the script and visualize the bundles using the plotly interactive visualization, which should automatically open in a new browser window.
bundle_html = myafq.viz_bundles(export=True, n_points=50)
plotly.io.show(bundle_html[0])